
#include "emixer_callbacks.h"
#include "emixer_alsa.h"


void
destroy_cb ( Ewl_Widget *w, void *event, void *data )
{
  // clean up our foo
  emixer_mixer_deinit();
  emixer_gui_deinit();
  ewl_widget_destroy ( w );
  ewl_main_quit();
}

void
mixer_upt_cb ( Ewl_Widget * w, void * event, void * data )
{
  long min,max; // get the element range
  int tmp = emixer_elem_vol_range_get ( (int)data, &min, &max );
  assert ( tmp == 0 );
  long vol = ((max-min)/100.0f)*ewl_range_value_get ( EWL_RANGE ( w ));

  // printf("vol : %i : >> %i:%i is %i\n",(int)data,min,max,vol);
  // NOTE: only mono sliders for now
  Emixer_Elem* elem = (Emixer_Elem*)data;
  emixer_elem_vol_now_set((int)data,0,vol);
  emixer_elem_vol_now_set((int)data,1,vol);
}

void
menu_mute_cb(Ewl_Widget* w, void* event, void* data)
{
   Emixer_Elem* elem = (Emixer_Elem*)data;
   elem->elem_is_muted=!elem->elem_is_muted;
   emixer_elem_mute_set(elem->elem_id,0,elem->elem_is_muted);
   emixer_elem_mute_set(elem->elem_id,1,elem->elem_is_muted);
   
   printf("MUTE: %s %i\n",emixer_elem_name_get(elem->elem_id),
	  elem->elem_is_muted);
}
